<template>
  <div id="#app">
    <header class="header">
      <router-link to="/mine"></router-link><span>用户信息</span>
    </header>
    <div class="tou">
      <p>我的头像</p>
      <span><input type="file" /><i class="iconfont iconyoujiantou"></i></span>
    </div>
    <div class="name">
      <p>昵称</p>
      <span><input type="text" /><i class="iconfont iconyoujiantou"></i></span>
    </div>
    <div class="sex">
      <p>性别</p>
      <span><span>男</span><i class="iconfont iconyoujiantou"></i></span>
    </div>
    <div class="phone">
      <p>手机号</p>
      <span
        ><span>{{ phone }}</span
        ><i class="iconfont iconyoujiantou"></i
      ></span>
    </div>
    <div class="save"><button @click="tui">保存</button></div>
    <div class="tui"><button @click="tui">退出登录</button></div>
    <!-- 弹框提示 -->
    <div id="tsk" class="tsk" v-bind:style="{ display: blockNone }">
      <p style="margin-left: 14px">退出成功！</p>
      <p>即将跳转</p>
    </div>
  </div>
</template>

<style lang="less" scoped>
/*初始化*/
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  list-style: none;
  text-decoration: none;
}
.header {
  position: fixed;
  top: 0;
  width: 100%;
  height: 50px;
  font-size: 14px;
  text-align: center;
  line-height: 53px;
  border-bottom: 1px solid #d8d8d8;
  /*position: relative;*/
  background: #ffffff;
  span {
    color: #000;
  }
  a {
    position: absolute;
    left: 0;
    top: 0;
    width: 50px;
    height: 50px;
    background: url("../../public/img/arrow-left.png") no-repeat center center;
    background-size: 50%;
  }
}
.tou {
  margin-top: 50px;
  display: flex;
  justify-content: space-between;
  /* margin: 10px; */
  font-size: 16px;
  padding: 11px 21px;
  align-items: center;
  border-bottom: 1px solid #d8d8d8;
  color: #666666;
  input {
    width: 208px;
    margin-right: 9px;
  }
  i {
    font-size: 24px;
  }
}
.name {
  display: flex;
  justify-content: space-between;
  height: 50px;
  font-size: 16px;
  padding: 19px 21px;
  align-items: center;
  border-bottom: 1px solid #d8d8d8;
  color: #666666;
  input {
    width: 208px;
    margin-right: 20px;
    border: none;
  }
}
.sex {
  display: flex;
  justify-content: space-between;
  height: 50px;
  font-size: 16px;
  padding: 19px 21px;
  align-items: center;
  border-bottom: 1px solid #d8d8d8;
  color: #666666;
  span:nth-child(1) {
    margin-right: 20px;
  }
}
.phone {
  display: flex;
  justify-content: space-between;
  height: 50px;
  font-size: 16px;
  padding: 19px 21px;
  align-items: center;
  border-bottom: 1px solid #d8d8d8;
  color: #666666;
  span:nth-child(1) {
    margin-right: 20px;
  }
}
.save {
  margin-top: 16px;
  text-align: center;
  button {
    width: 90%;
    height: 46px;
    background: #333333;
    font-size: 18px;
    color: #ffffff;
    border-radius: 4px;
    border: none;
  }
}
.tui {
  margin-top: 14px;
  text-align: center;
  button {
    width: 90%;
    height: 46px;
    background: #ffffff;
    font-size: 18px;
    color: #666666;
    border-radius: 4px;
    border: 1px solid #ccc;
  }
}
.tsk {
  width: 170px;
  height: 70px;
  line-height: 32px;
  text-align: center;
  background: #000;
  opacity: 0.5;
  color: #c2c5c9;
  font-size: 30px;
  border-radius: 6px;
  position: fixed;
  top: 31%;
  left: 52%;
  font-size: 20px;
  transform: translate(-50%, -50%);
}
</style>

<script>
export default {
  data() {
    return {
      blockNone: "none", //默认设置为隐藏
      phone: "", //手机号码
    };
  },
  methods: {
    tui() {
      this.$axios.post("http://47.111.93.194:3003/list", {
          user: JSON.parse(localStorage.getItem("user")).user,//拿到本地的用户名
          list: JSON.parse(localStorage.getItem("biao1")),//拿到biao1
        })

        //点击退出登录删除user和biao1
      localStorage.removeItem("user");
      localStorage.removeItem("biao1");
      this.blockNone = "block"; //提示框显示
      setTimeout(() => {
        this.blockNone = "none";
        this.$router.push({ path: "/mine" });
      }, 2000); //两秒消失
    },
  },
  mounted() {
    if (localStorage.getItem("user") != null) {
      //到本地拿数据
      var ff = JSON.parse(localStorage.getItem("user"));
      console.log(ff);
      this.phone = ff.phone;
    }
  },
};
</script>